#include <stdio.h>

int main()
{

    struct Person
    {
        char name[50];
        int age;
        float height;
    }person2;

    struct Person person1;
// 创建和使用结构体变量
    // Assign values to the struct
    strcpy(person1.name, "John");
    person1.age = 30;
    person1.height = 1.78;

    // 输出
    printf("Name: %s\n", person1.name);
    printf("Age: %d\n", person1.age);
    printf("Height: %.2f\n", person1.height);
//结构体数组
    struct Person people[3];

    strcpy(people[0].name, "Alice");
    people[0].age = 30;
    people[0].height = 1.75;

    strcpy(people[1].name, "Bob");
    people[1].age = 25;
    people[1].height = 1.80;

    for (int i = 0; i < 2; i++)
    {
        printf("Name: %s, Age: %d, Height: %.2f\n", people[i].name, people[i].age, people[i].height);
    }
    //指向结构体的指针
    struct Person *ptr;
    // Assign the address of person2 to ptr
    ptr = &person2;

    printf("ptr= %p\n", ptr);

    strcpy(ptr->name,"Alice");
    ptr->age = 30;
    ptr->height = 1.75;

    printf("pointer： Name: %s, Age: %d, Height: %.2f\n", ptr->name, ptr->age, ptr->height);
}